package com.itheima.user.controller;


import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import com.itheima.common.vo.PageResultVo;
import com.itheima.common.vo.ResultVo;
import com.itheima.user.dto.ApUserRealnamePageRequestDto;
import com.itheima.user.pojo.ApUserRealname;
import com.itheima.user.service.ApUserRealnameService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.itheima.core.controller.AbstractCoreController;

import java.util.Map;

/**
 * @description <p>APP实名认证信息</p>
 *
 * @version 1.0
 * @package com.itheima.user.controller
 */
@Api(value="ApUserRealnameController",tags = "APP实名认证信息")
@RestController
@RequestMapping("/auth")
public class ApUserRealnameController extends AbstractCoreController<ApUserRealname> {

    private ApUserRealnameService apUserRealnameService;

    @Autowired
    public ApUserRealnameController(ApUserRealnameService apUserRealnameService) {
        super(apUserRealnameService);
        this.apUserRealnameService=apUserRealnameService;
    }

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("分页查询")
    public PageResultVo<ApUserRealname> findPage(@RequestBody ApUserRealnamePageRequestDto dto){
        PageResultVo<ApUserRealname> pageResultVo = apUserRealnameService.findPage(dto);
        return pageResultVo;
    }
    /**
     * 驳回
     * @param paramMap
     * @return
     */
    @PostMapping("/authFail")
    @ApiOperation("审核驳回")
    @DynamicParameters(
            name = "paramMap",
            properties = {
                    @DynamicParameter(name = "id", required = true,value = "实名认证id", dataTypeClass = Integer.class),
                    @DynamicParameter(name = "msg", required = true,value = "原因", dataTypeClass = String.class)
            }
    )
    public ResultVo authFail(@RequestBody Map<String,Object> paramMap){
        apUserRealnameService.authFail(paramMap);
        return ResultVo.ok();
    }

    /**
     * 审核 - 通过
     * @param paramMap
     * @return
     */
    @PostMapping("/authPass")
    @ApiOperation("审核通过")
    @DynamicParameters(
            name = "paramMap",
            properties = {
                    @DynamicParameter(name = "id", required = true,value = "实名认证id", dataTypeClass = Integer.class)
            }
    )
    public ResultVo authPass(@RequestBody Map<String,Object> paramMap){
        apUserRealnameService.authPass(paramMap);
        return ResultVo.ok();
    }
}

